# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : Multi_Threading.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/15 上午10:21
"""
from time import ctime, sleep
import threading  # 导入多线程模块


class Show:
    def __init__(self):
        print(f'This is __init__ method. {self.get_class_name()} class startup')

    def begin(self):
        print("节目开始")

    def end(self):
        print("节目结束")

    def sing(self):
        for i in range(10):
            print(f'唱歌进行中 at {ctime()}')
            sleep(1)

    def dance(self):
        for i in range(10):
            print(f'跳舞进行中 at {ctime()}')
            sleep(1)

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    def __del__(self):
        print(f'This is __del__ method. The {self.get_class_name()} class has been recycled')


if __name__ == '__main__':
    print(ctime())
    s = Show()
    s.begin()
    # s.sing()
    # s.dance()
    # 创建两个线程 target = s.dance 后面不能加()
    # target参数表明要执行的函数名称s.dance,args表示被执行的函数需要什么参数
    th1 = threading.Thread(target=s.dance, args=())
    th2 = threading.Thread(target=s.sing, args=())
    th1.start()
    th2.start()
    #主线程等待其他线程执行完毕才会继续执行
    th1.join()
    th2.join()
    s.end()
